console.log("111111111111")

const queue = require('fastq')(worker, 4)

let data = [
    {"num": "42"},
    {"num": "22"},
    {"num": "44"},
    {"num": "66"},
    {"num": "77"},
    {"num": "42"},
    {"num": "22"},
    {"num": "44"},
    {"num": "66"},
    {"num": "77"},
];

data.forEach(function (res) {
    queue.push(res, function (err, result) {
        if (err) {
            throw err
        }
        console.log('the result is', result)
    })
})


function worker(arg, cb) {
    setTimeout(function () {
        cb(null, arg['num'] * 2)
    }, 1000);
}

